package com.headwind.logistics.log.Service.impl;

import com.headwind.logistics.log.Service.intl.LogServiceIntl;
import com.headwind.logistics.log.dto.FunLogEmpDTO;
import com.headwind.logistics.log.mapper.FunctionLogMapper;
import com.headwind.logistics.log.mapper.LogMapper;
import com.headwind.logistics.log.pojo.LoginLog;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

/**
 * @Author 小恶魔
 * @Date 2020-07-20 22:12
 * @Version 1.0
 * @DESCRIPTION 登录日志业务逻辑层实现类
 */
@Service
public class LogServiceImpl implements LogServiceIntl {

    @Resource
    private LogMapper logMapper;  //日志数据访问层

    @Resource
    private FunctionLogMapper functionLogMapper;  //功能日志数据访问层
    /**
     * 获取全部登录日志信息
     * @param page
     * @param rows
     * @return
     */
    @Override
    public List<LoginLog> queryAllLoginLogPage(Integer page, Integer rows) {

        if (page!=null){
            page = (page-1)*rows;
        }

        return logMapper.queryAllLoginLogPage(page, rows);
    }

    /**
     * 批量删除登录日志
     * @param logIdList
     * @return
     */
    @Override
    public Integer batchDeleteLoginLogById(String logIdList) {

        String[] logIds = logIdList.split("-");

        return logMapper.batchDeleteLoginLogById(logIds);
    }

    /**
     * 查询出所有的功能日志信息
     * @param page
     * @param rows
     * @return
     */
    @Override
    public List<FunLogEmpDTO> queryAllFunctionLog(Integer page, Integer rows) {

        if (page != null){
            page = (page-1)*rows;
        }

        return functionLogMapper.queryAllFunctionLog(page, rows);
    }

    /**
     * 批量删除功能操作日志
     * @param funcLogList
     * @return
     */
    @Override
    public Integer batchDeleteFunctionLogById(String funcLogList) {
        //分割成数组
        String[] funcIds = funcLogList.split("-");


        return functionLogMapper.batchDeleteFunctionLogById(funcIds);
    }
}
